#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define MAXN 2333
using namespace std;

int p[MAXN][MAXN], w[MAXN], n, q;

inline int read() {
	int k = 0;
	char c = getchar();
	for(;!isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k;
} 

int find_T(int a) {
	int k = 1;
	while(true) {
		k *= 2;
		if(k > a) return k / 2;
	}
}

int main() {
	
	n = read();
	memset(p, 127, sizeof(p));
	for(int  i = 1; i <= n; i++) {
		w[i] = read();
		p[i][1] = w[i]; 
	}
	
	for(int i = n; i >= 1; i--) {
		for(int j = 2; j <= n; j *= 2) {
			p[i][j] = min(p[i][j / 2], p[i + j / 2][j / 2]); 
		}
	}
	
	q = read();
	
	while(q--) {
		int x = read();
		int y = read();
		int z = y - x;
		int t = find_T(z);
		printf("%d\n",min(p[x][t], p[y - t + 1][t]));
	}
	
	return 0;
	
}
